<!DOCTYPE html>
<!--
==========================================================================
云捷GO自动生成列表页面代码,只生成一次,按需修改.
生成日期：2021-08-17 14:40:38
生成路径: template/module/attachment/list.html
生成人：gfcms
==========================================================================
-->
<html lang="zh">
<head>
    {{template "header" (ossUrl)}}
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>文件名：</p>
                            <input type="text" name="filename"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            {{getPermiButton .Session.uid "module:attachment:add" "$.operate.add()" "新增" "btn btn-success" "fa fa-plus"}}
            {{getPermiButton .Session.uid "module:attachment:edit" "$.operate.edit()" "修改" "btn btn-primary single disabled" "fa fa-edit"}}
            {{getPermiButton .Session.uid "module:attachment:remove" "$.operate.removeAll()" "删除" "btn btn-danger multiple disabled" "fa fa-remove"}}
            {{getPermiButton .Session.uid "module:attachment:export" "$.table.exportExcel()" "导出" "btn btn-warning" "fa fa-download"}}
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
{{template "footer" (ossUrl)}}

<script type="text/javascript">
    var editFlag = '{{hasPermi .Session.uid "module:attachment:edit"}}';
    var removeFlag = '{{hasPermi .Session.uid "module:attachment:remove"}}';


    var prefix = ctx + "module/attachment";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "附件管理",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'filename',
                    title: '文件名'
                },
                {
                    field: 'filepath',
                    title: '文件路径'
                },
                {
                    field: 'filesize',
                    title: '文件大小',
                    formatter: function (value, row, index) {
                        return sizeTostr(value);
                    }
                },
                {
                    field: 'imagewidth',
                    title: '图片宽度',
                    formatter: function (value, row, index) {
                        return value + "px";
                    }
                },
                {
                    field: 'imageheight',
                    title: '图片高度',
                    formatter: function (value, row, index) {
                        return value + "px";
                    }
                },
                {
                    field: 'create_time',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
</script>
<script>
    function sizeTostr(size) {
        var data = "";
        if (size < 0.1 * 1024) { //如果小于0.1KB转化成B
            data = size.toFixed(2) + "B";
        } else if (size < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB
            data = (size / 1024).toFixed(2) + "KB";
        } else if (size < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
            data = (size / (1024 * 1024)).toFixed(2) + "MB";
        } else { //其他转化成GB
            data = (size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
        }
        var sizestr = data + "";
        var len = sizestr.indexOf("\.");
        var dec = sizestr.substr(len + 1, 2);
        if (dec == "00") {//当小数点后为00时 去掉小数部分
            return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
        }
        return sizestr;
    }
</script>
</body>
</html>